import pandas as pd
import math

demo = 'TOP20W词表无线.xlsx'
data = pd.read_excel(io=demo, sheet_name='无线')
# demo = 'test.xlsx'
# data = pd.read_excel(io=demo, sheet_name='Sheet1')

df1 = pd.DataFrame(data)
# print(data)

list1 = df1['一级类目'].unique()
# print(df1)
print(len(list1))

for i in range(5):
    print(str(i + 1) + '，一级类目: ' + list1[i])
    # df1.set_index('一级类目', inplace=True)
    bl1 = df1['一级类目'].isin([list1[i]])
    df2 = df1.loc[bl1]
    # print(df2)
    # print()

    list2 = df2['二级类目'].unique()
    # print(len(list2))
    for j in range(len(list2)):
        if bool(pd.isnull(list2[j])) != True:
            print('     ' + str(j) + '，二级类目: ' + list2[j])
        bl2 = df2['二级类目'].isin([list2[j]])
        df3 = df2.loc[bl2]
        # print(df3)
        # print()

        list3 = df3['三级类目'].unique()
        # print(len(list3))
        for z in range(len(list3)):
            if bool(pd.isnull(list3[z])) != True:
                print('三级类目')
                bl3 = df3['三级类目'].isin([list3[z]])
                df4 = df3.loc[bl3]
                print(df4)
                print()

    print()
